<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title></title>
</head>

<body>
</body>
<script>
   (function(){
       var obj = {
           x:1,
           fn:function(){
               function f(){
                   console.log(this);
                   console.log(this.x);
               }
               f();
           }
       }
       obj.fn();
   })();

   (function(){
       function fn1(){
           console.log(this);
           function fn2(){
               console.log(this);
           }
           fn2();
       }
       fn1();
   })
</script>

</html>